package com.peakmain.homemodule.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;

import com.peakmain.baselibrary.recyclerview.adapter.CommonRecyclerAdapter;
import com.peakmain.baselibrary.recyclerview.adapter.ViewHolder;
import com.peakmain.homemodule.R;
import com.peakmain.wanandroid.netmodule.bean.home.HotkeyBean;

import java.util.List;

/**
 * author: peakmain
 * createdata：2019/7/23
 * mail: 2726449200@qq.com
 * desiption:
 */
public class HotKeyAdapter extends CommonRecyclerAdapter<HotkeyBean>{
    public HotKeyAdapter(Context context, List<HotkeyBean> data){
        super(context, data, R.layout.recycler_view_hotkey);
    }

    @Override
    public void convert(ViewHolder holder, HotkeyBean item) {
        StringBuilder stringBuilder=new StringBuilder();
        int adapterPosition = holder.getAdapterPosition();
        stringBuilder.append(adapterPosition+1).append("、").append(item.getName());
        SpannableString builder=new SpannableString(stringBuilder.toString());
        if(adapterPosition==0||adapterPosition==1||adapterPosition==2){
            ForegroundColorSpan foregroundColorSpan=new ForegroundColorSpan(Color.RED);
            builder.setSpan(foregroundColorSpan,0,2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }


        holder.setText(R.id.tv_search,builder);
    }
}
